#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

int main(void)
{
    char str[3][51]= {0};
    struct iovec v[] = 
    {
        {(void*)str[0], sizeof(str[0]) - 1},
        {(void*)str[1], sizeof(str[1]) - 1},
        {(void*)str[2], sizeof(str[2]) - 1}
    };


    int fd = open("buccaneer.txt", O_RDONLY);
    if (fd == -1)
    {
        printf("error = %d\n", errno);
        perror("open");
    }
    ssize_t res = readv(fd, v, 3);
    printf("read result %ld\n", res);

    for (int i = 0; i < 3; i++)
    {
        printf("%d: %s\n", i, str[i]);
    }

    close(fd);
}